import java.util.Scanner;

public class 特殊年份 {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        //有多少行
        int N;
        N=5;
        int year;
        int res=0;
        int ge;
        int shi;
        int bai;
        int qian;
        while(N>0){
            year=scan.nextInt();
            //拆
          ge=year%10;
          shi=(year/10%10);
          bai=year/100%10;
          qian=year/1000;
          if((qian==shi)&&(ge==bai+1))
              res++;
            N--;
        }
        System.out.println(res);
    }
}
